#include "FileBuffer.h"

#include <cstddef>  // for NULL
#include <cassert>

CStreamBuffer::CStreamBuffer( void ) : m_pBuffer( NULL ), m_Offset( 0 ), m_Length( 0 ),
                                       m_pCurrentPos( NULL ), m_MaxLength( 655360 )
{
    //ctor
}

CStreamBuffer::~CStreamBuffer( void )
{
    //dtor
}

int CStreamBuffer::Create( int length )
{
    assert( length > 0 );

    m_Length = length;

    if( m_pBuffer != NULL )
    {
        delete [] m_pBuffer;
        m_pBuffer = NULL;
    }

    m_pBuffer = new char[m_Length];

    return 0;
}

int CStreamBuffer::Create( void )
{
    if( m_pBuffer != NULL )
    {
        delete [] m_pBuffer;
        m_pBuffer = NULL;
    }

    m_pBuffer = new char[m_MaxLength];

    return 0;
}

void CStreamBuffer::Destroy( void )
{
    if( m_pBuffer != NULL )
    {
        delete [] m_pBuffer;
        m_pBuffer = NULL;
    }
}
